package Example;
//输入某年某月某日，判断这一天是这一年的第几天？ 注意: 闰年的二月多一天

import java.util.Scanner;

public class Demo13 {
    public static boolean judge(int year) {
        if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0) ;
        return true;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入日期（空格隔开）");
        int year = scan.nextInt();
        int month = scan.nextInt();
        int day = scan.nextInt();
        int dayofyear = 0;
        if (month == 1) {
            dayofyear = day;
            System.out.println("这一天是" + year + "年的第" + dayofyear + "天");
        } else {
            if (judge(year)) {
                switch (month) {
                    case 2:
                        dayofyear = 31 + day;
                        break;
                    case 3:
                        dayofyear = 31 + 29 + day;
                        break;
                    case 4:
                        dayofyear = 31 + 29 + 31 + day;
                        break;
                    case 5:
                        dayofyear = 31 + 29 + 31 + 30 + day;
                        break;
                    case 6:
                        dayofyear = 31 + 29 + 31 + 30 + 31 + day;
                        break;
                    case 7:
                        dayofyear = 31 + 29 + 31 + 30 + 31 + 30 + day;
                        break;
                    case 8:
                        dayofyear = 31 + 29 + 31 + 30 + 31 + 30 + 31 + day;
                        break;
                    case 9:
                        dayofyear = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + day;
                        break;
                    case 10:
                        dayofyear = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day;
                        break;
                    case 11:
                        dayofyear = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day;
                        break;
                    case 12:
                        dayofyear = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day;
                        break;
                    default:
                        System.out.println("输入有误。。。");
                }
            } else {
                switch (month) {
                    case 2:
                        dayofyear = 31 + day;
                        break;
                    case 3:
                        dayofyear = 31 + 28 + day;
                        break;
                    case 4:
                        dayofyear = 31 + 28 + 31 + day;
                        break;
                    case 5:
                        dayofyear = 31 + 28 + 31 + 30 + day;
                        break;
                    case 6:
                        dayofyear = 31 + 28 + 31 + 30 + 31 + day;
                        break;
                    case 7:
                        dayofyear = 31 + 28 + 31 + 30 + 31 + 30 + day;
                        break;
                    case 8:
                        dayofyear = 31 + 28 + 31 + 30 + 31 + 30 + 31 + day;
                        break;
                    case 9:
                        dayofyear = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + day;
                        break;
                    case 10:
                        dayofyear = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day;
                        break;
                    case 11:
                        dayofyear = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day;
                        break;
                    case 12:
                        dayofyear = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day;
                        break;
                    default:
                        System.out.println("输入有误。。。");
                }
            }
            System.out.println("这一天是" + year + "年的第" + dayofyear + "天");
        }
    }
}
